package com.kayeah82.application.avatar.qq.security;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author kayeah82
 * */
public class DefaultSecurityChain implements SecurityChain {

    private final List<? extends SecurityFilter> filters;

    private int currentPosition = 0;

    public DefaultSecurityChain(List<? extends SecurityFilter> filters) {
        this.filters = filters;
    }

    @Override
    public void doFilter(HttpServletRequest request) {
        if (currentPosition == filters.size()) {
            return;
        }
        currentPosition++;
        SecurityFilter current = filters.get(currentPosition - 1);
        current.doFilter(request, this);
    }

}
